% Function to compute Cross and auto spectra
% from given individual spectra 'Channel'
% Assumes the order Ex Ey Hx Hy Hz and Hxr Hyr (if any)
% parzen radius is supplied through second argument
% sepctra is packed in EDI standard 
% NOT CHECKED 28.08.2002
% CHECKED OK 03.09.2002
% latest date 30.10.2002


function[SPM] = CompuSPM(Channel, par,TL,TR),

a = size(Channel);
nchannel = a(2);

for i = 1:nchannel,
   for j = 1:i,
      talkal = doparzen(Channel(:,j),conj(Channel(:,i)),TL,TR,par);
      if i ~= j,
        SPM(i,j) = real(talkal);
        SPM(j,i) = (-1)*imag(talkal); %inserted -1 ->30.10.2002
% for respecting the complex quadrangle
      elseif i == j,
         SPM(i,j) = talkal;
         end;
   end;
end;

